WorkflowApi
Overview
The API container. It contains all the API objects and functionality. Used to access and manipulate the conversation data.
- From version: 2020.20
Properties
Events
Properties
canvas
canvas: Canvas
The Workflow container. The Canvas is used for accessing properties and functions related to visualization and rendering.
saveButton.onclick = () => {
workflowApi.canvas.showSpinner();
workflowApi.currentThread.save().finally(() =>{
workflowApi.canvas.hideSpinner();
workflowApi.canvas.refresh();
})
}
currentThread
currentThread: WorkflowThread
The workflow thread for the current context. You will use the thread for reading and writing workflow data.
const saveButton = document.getElementById("send-button");
enums
enums: Enums
Enumerations of standard values used in the API. Enums are used to make logical and structural distinctions between different parts of the API.
if(workflowApi.session.theme === workflowApi.enums.ThemeType.Light){
document.getElementById("mainObject").style.color = "white";
}
externalLibraries
externalLibraries: ExternalLibraries
The collection of external, third party libraries. Use this to include and then access third party libraries for building custom workflow.
workflowApi.externalLibraries.addExternalLibraries(["https://cdn.plot.ly/plotly-latest.min.js"]);
session
session: Session
Session is an object for properties related to the current run. Session properties include the current user signed into the app and the app's chosen design theme.
if(!allowedUsers.some(user => user.id === workflowApi.session.currentUser.id)) {
canvasObject.classList.add("disable");
}
utilities
utilities: Utilities
API utility functions. Utilities for general operations to simplify methods or for items that are not accessible through API objects.
const ulElement = document.createElement("ul");
workflowApi.utilities.getUsersAndRoles().forEach(function(contact){
const optionLi = document.createElement("li");
optionLi.append(contact.name);
ulElement.appendChild(optionLi)
});
Events
onBeforeUnload
onBeforeUnload (): void
This method is triggered from the Workflow infrastructure when the window is about to be closed. Implement this function if you need to clean or delete objects that were created during the workflow exercise.
function main(){
workflowApi.onBeforeUnload = () =>{
workflowApi.currentThread.save();
}
}
Returns void
onFormLoad
onFormLoad (): void
This method is triggered from the workflow infrastructure when the form finishes loading. Implement this function to initiate your model and populate your form elements.
function main(){
workflowApi.onFormLoad = () => {
buildView(y);
}
}
Returns void
onSave
onSave (): Promise<void>
This method is triggered from the workflow infrastructure after a workflow's object was saved. Implement this function if you need to manipulate your data and save it.
function main(){
workflowApi.onSave = () =>{
workflowApi.currentThread.title = "hardcoded title";
}
}
Returns Promise<void>